import com.fz.Mapper.UserMapper;
import com.fz.entity.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by xiao zeng on 2017/6/21.
 */
public class UserDome {
   protected SqlSessionFactory sf;
   protected SqlSession session;

   @Before
   public void inio() throws IOException {
       String resoures="mybatis-conf.xml";
       InputStream inputStream = Resources.getResourceAsStream(resoures);
       this.sf = new SqlSessionFactoryBuilder().build(inputStream);
       this.session = sf.openSession();

   }
   @After
   public void close(){
       session.commit();
       session.close();
   }

   @Test
   public void  show(){
       UserMapper  sdao =  session.getMapper(UserMapper.class);

       Map<String,Object> m  = new HashMap<String, Object>();
       m.put("acount","admin");
//       m.put("uacount","bb");
       List<User> mm = sdao.UserQuery(m);
       System.out.println(mm);
       for (User u : mm){
           System.out.println(u.getUserInfo().getName());
       }
   }
}
